<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding:0;
            margin:0;
            list-style: none;
        }
        .tab{
            width:300px;
            height:300px;
            border:1px solid red;
            margin:100px auto;
        }
        .tab input{
            width:100px;
            height:30px;
            float:left;
        }
        .tab .active{
            background: paleturquoise;
            color:#fff;
        }
        .tab li{
            width:300px;
            height:270px;
            background: purple;
            font-size: 30px;
            color:#fff;
            text-align: center;
            line-height: 270px;
            display: none;
        }
        .tab .show{
            display: block;
        }
        .tab section{
            overflow: hidden;
        }
        a{
            color:yellow;
            font-size:50px;
            font-weight:bloder;
            position:absolute;
            text-decoration:none;
        }
       .tab .btn1{
            left:0px;
            top:130px;
            z-index:1;
        }
        .tab .btn2{
            right:0px;
            top:130px;
            z-index:1;
        }
        .tab{
            position:relative;
        }

    </style>
    <script>

        class Tab{
            constructor(str){
                //属性
                this.parent=document.querySelector(str);
                this.aBtnList=this.parent.querySelectorAll('input');
                this.aLiList=this.parent.querySelectorAll('li');
                //初始化事件
                this.show();
            }
            show(){
                let _this=this;
                for(let i=0; i<this.aBtnList.length;i++){
                    this.aBtnList[i].onclick=function(){
                        _this.index=i;
                        _this.fn(i);
                    };
                }
            }
            fn(i){
                // console.log(this);
                for(var j=0;j<this.aLiList.length;j++){
                    this.aBtnList[j].className='';
                    this.aLiList[j].className='';
                }
                this.aLiList[i].className='show';
                this.aBtnList[i].className='active';
            }
        }


        class ZuoYou extends Tab{
            constructor(str){
                //继承属性
                super(str);
                this.anniu();
                this.btn1 = document.getElementsByClassName("btn1")[0];
                this.btn2 = document.getElementsByClassName("btn2")[0];


            }
            anniu(){
                var _this=this;
                var btn1 = this.btn1;
                var btn2 = this.btn2;

            }
        }



        window.onload=function(){

            new ZuoYou("#tab1");

        }


    </script>
</head>
<body>
<div class="tab" id="tab1">
    <section class="btnBox">
        <input type="button" value="按钮1" class="active">
        <input type="button" value="按钮2">
        <input type="button" value="按钮3">
    </section>
    <ul>
        <li class="show">1</li>
        <li>2</li>
        <li>3</li>
    </ul>
    <a href="javascript:;" class="btn1"><</a>
    <a href="javascript:;" class="btn2">></a>
</div>
</body>
</html>